package com.ruoyi.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Arrays;

/**
 * 百度身份证识别类型枚举
 * 1-身份证正面图，2-身份证反面图，3-营业执照
 *
 * @author liaowen
 * @date 2024/11/7 18:24
 */
@Getter
public enum BaiduOcrParamEnum {
    /**
     * 百度身份证识别类型枚举
     * 1-正面，2-背面
     */
    FRONT(1, "front", "身份证正面图"),
    BACK(2, "back", "身份证反面图"),
    BUSINESS(3, "", "营业执照"),
    ;

    @JsonValue
    @EnumValue
    private final Integer code;
    private final String value;
    private final String desc;

    BaiduOcrParamEnum(Integer code, String value, String desc) {
        this.code = code;
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator
    public static BaiduOcrParamEnum fromCode(Integer code) {
        return Arrays.stream(BaiduOcrParamEnum.values()).filter(e -> e.getCode().equals(code)).findFirst().orElse(null);
    }

}
